// do /Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Code/extract_ee_2012_2014.do

pause on

global  pathdata_1 = "/Users/shoude/Dropbox/eegap/EEgap_data/Prospector_LBNL"
*global  pathdata_2 = "/Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Results_estimation"
global  pathresults = "/Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Results_estimation"

/*
Code structure:
Part 1. Import CCMS data prior to 09.2014
Part 2. Import CCMS data after 09.2014
Part 3. 
*/

*global  pathresults ="/Volumes/RECHERCHE/FAC/HEC/DEEP/shoude/default/D2c/eegap/EEgap_data_code_heter_SM/Results_Estimation"
*global  Est_pathresults = "/Volumes/RECHERCHE/FAC/HEC/DEEP/shoude/default/D2c/eegap/EEgap_data_code_heter_SM/Results_Estimation"

//Part 1. Import CCMS data prior to 09.2014

insheet using $pathdata_1/ccms_refrigerator_archived.csv, comma clear name 

 destring annualenergyusekhperyear volumeadjustedcuf productclassdescription, force replace
 split datecertified, parse(.)
 ren datecertified1 day_certified
 ren datecertified2 month_certified
 ren datecertified3 year_certified
 gen y20="20"
 replace year_certified = y20 + year_certified
 destring *_certified, replace
 
 pause
 
 ren annualenergyusekhperyear kwh_y
 ren volumeadjustedcuf AV
 gen meps_2001 = 8.82*AV + 248.4
 replace meps_2001 = 9.80*AV + 276.0 if productclassdescription == 3
 replace meps_2001 = 4.91*AV + 507.5 if productclassdescription == 4
 replace meps_2001 = 4.60*AV + 459.0 if productclassdescription == 5
 replace meps_2001 = 10.2*AV + 356.0 if productclassdescription == 6
 replace meps_2001 = 10.10*AV + 406.0 if productclassdescription == 7
 replace meps_2001 = 7.55*AV + 258.3 if productclassdescription == 8 
 replace meps_2001 = 12.43*AV + 326.1 if productclassdescription == 9
 replace meps_2001 = 9.88*AV + 143.7 if productclassdescription == 10
 replace meps_2001 = 10.70*AV + 299.0 if productclassdescription == 11
 replace meps_2001 = 7.00*AV + 398.0 if productclassdescription == 12
 replace meps_2001 = 12.70*AV + 355.0 if productclassdescription == 13
 replace meps_2001 = 7.60*AV + 501.0 if productclassdescription == 14
 replace meps_2001 = 13.10*AV + 367.0 if productclassdescription == 15
 replace meps_2001 = 9.78*AV + 250.8 if productclassdescription == 16
 replace meps_2001 = 11.40*AV + 391.0 if productclassdescription == 17
 replace meps_2001 = 10.45*AV + 152.0 if productclassdescription == 18 
  
save $pathdata_1/ccms_refrigerator_pre_092014, replace 
  
  
  
  
  
 /*
 gen meps_2014 = 7.99*AV + 225.0
 replace meps_2014 = 7.99*AV + 225.0 if productclassdescription == 2
 replace meps_2014 = 9.80*AV + 276.0 if productclassdescription == 3
 replace meps_2014 = 4.91*AV + 507.5 if productclassdescription == 4
 replace meps_2014 = 4.60*AV + 459.0 if productclassdescription == 5
 replace meps_2014 = 10.2*AV + 356.0 if productclassdescription == 6
 replace meps_2014 = 10.10*AV + 406.0 if productclassdescription == 7
 replace meps_2014 = 7.55*AV + 258.3 if productclassdescription == 8 
 replace meps_2014 = 12.43*AV + 326.1 if productclassdescription == 9
 replace meps_2014 = 9.88*AV + 143.7 if productclassdescription == 10
 replace meps_2014 = 10.70*AV + 299.0 if productclassdescription == 11
 replace meps_2014 = 7.00*AV + 398.0 if productclassdescription == 12
 replace meps_2014 = 12.70*AV + 355.0 if productclassdescription == 13
 replace meps_2014 = 7.60*AV + 501.0 if productclassdescription == 14
 replace meps_2014 = 13.10*AV + 367.0 if productclassdescription == 15
 replace meps_2014 = 9.78*AV + 250.8 if productclassdescription == 16
 replace meps_2014 = 11.40*AV + 391.0 if productclassdescription == 17
 replace meps_2014 = 10.45*AV + 152.0 if productclassdescription == 18 
 */

 

 
 